<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>使用 **对象字面量**、**new Object** 、**构造函数** 三种方式创建对象</title>
	</head>
	<body>
		<p>5、小明家里有三个人，爸爸和妈妈，小明是男的，今年18岁，兴趣爱好是打篮球和读书，
				<br />爸爸是软件程序员，妈妈是UI设计师，小明家在深圳南山有一套100平方的房子，
				<br />户型是三房一厅，今年小明家刚买了一辆特斯拉Model3.</p>
	</body>
	<script>
		
console.log("字面量---------------------------------------------------------------")

		let xiaoming = {
		    name:"小明",
		    sex:"男",
		    age:18,
			hobby:"打篮球和读书"
		}
		console.log(xiaoming);
		
		let baba = {
			name:"爸爸",
			job:"软件程序员"
		}
		console.log(baba);
		
		let mama = {
			name:"妈妈",
			job:"UI设计师"
		}
		console.log(mama);
		
		let zichan1 = {
			name:"房子",
			type:"三房一厅",
			size:"100平方"
		}
		console.log(zichan1);
		
		let zichan2 = {
			name:"车子",
			pinpai:"特斯拉",
			xinhao:"Model3"
		}
		console.log(zichan2);
		
console.log("new Object-----------------------------------------------------------")	

		let xiaoming1 = new Object();
		xiaoming.name = "小明";
		xiaoming.sex = "男";
		xiaoming.age = 18;
		xiaoming.hobby = "打篮球和读书";
		console.log(xiaoming);
		
		let baba1 = new Object();
		baba.name = "爸爸";
		baba.job = "软件程序员";
		console.log(baba);
		
		let mama1 = new Object();
		mama.name = "妈妈";
		mama.job = "UI设计师";
		console.log(mama);
		
		let zichan3 = new Object();
		zichan3.name = "房子";
		zichan3.type = "三房一厅";
		zichan3.size = "100平方";
		console.log(zichan3);
		
		let zichan4 = new Object();
		zichan4.name = "车子";
		zichan4.pinpai = "特斯拉";
		zichan4.xinhao = "Model3";
		console.log(zichan4);
		
console.log("构造函数--------------------------------------------------------------")

		function Person(name,sex,age,hobby){
		    this.name = name;
		    this.sex = sex;
		    this.age = age;
			this.hobby = hobby;
		}
		let xiaoming2 = new Person("小明","男","18","打篮球和读书");
		console.log(xiaoming);
		
		function Jiaren(name,job){
			this.name = name;
			this.job = job;
		}
		let baba2 = new Jiaren("爸爸","软件程序员");
		console.log(baba);
		let mama2 = new Jiaren("妈妈","UI设计师");
		console.log(mama);
		
		function Zichan1(name,type,size){
			this.name = name;
			this.type = type;
			this.size = size;
		}
		let house = new Zichan1("房子","三房一厅","100平方");
		console.log(house);
		
		function Zichan2(name,pinpai,xinhao){
			this.name = name;
			this.pinpai = pinpai;
			this.xinhao = xinhao;
		}
		let car = new Zichan2("车子","特斯拉","Model3");
		console.log(car);
		
	</script>
	</html>
